package com.zhijian.medical.controller;


import com.zhijian.medical.api.CommonResult;
import com.zhijian.medical.entity.po.ExperimentFishReport;
import com.zhijian.medical.entity.vo.request.ExperimentReportSearchVo;
import com.zhijian.medical.entity.vo.response.ExperimentReportListVo;
import com.zhijian.medical.service.FishReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author li xiao dong
 * @since 2022-08-14
 */
@Slf4j
@RestController
@Api(tags = "【FISH实验】报告")
@RequestMapping("/fish")
public class FishReportController {

    @Autowired
    private FishReportService reportService;

    @PutMapping("/experiment/report/{id}")
    @ApiOperation("修改报告")
    public CommonResult<Boolean> update(@PathVariable("id") Long id, @RequestBody ExperimentFishReport experimentFishReport) {
        experimentFishReport.setId(id);
        return CommonResult.success(reportService.update(experimentFishReport));
    }

    @GetMapping("/experiment/report/{id}")
    @ApiOperation("报告详情")
    public CommonResult<ExperimentFishReport> detail(@PathVariable("id") Long id) {
        return CommonResult.success(reportService.detail(id));
    }


    @GetMapping("/experiment/report/newest")
    @ApiOperation("获取最新报告")
    public CommonResult<ExperimentFishReport> newest() {
        return CommonResult.success(reportService.newest());
    }


    @PostMapping("/experiment/report/list")
    @ApiOperation("查询报告")
    public CommonResult<List<ExperimentReportListVo>> list(@RequestBody ExperimentReportSearchVo experimentReportSearchVo) {
        return CommonResult.success(reportService.list(experimentReportSearchVo));
    }

    @PostMapping("/experiment/report")
    @ApiOperation("创建报告")
    public CommonResult<Boolean> create(@RequestBody ExperimentFishReport experimentFishReport) {
        return CommonResult.success(reportService.create(experimentFishReport));
    }

}

